<?php
class Event extends AppModel {

     var $name = 'Event';
     var $validate = array();
     
    function v_fUpdateEvent($the_i_LucomId,$the_sz_Event){
        // Check exists event
        $event = $this->find('first',array('conditions'=>array('Event.user_id'=>$the_i_LucomId)));

        if(!empty($event) )
        {        
             $a_data =array('id'=>$event['Event']['id'],'user_id'=>$the_i_LucomId,'date'=>$the_sz_Event);
        }else
        {
             $a_data =array('user_id'=>$the_i_LucomId,'date'=>$the_sz_Event);
            
        }
        
        return $this->save($a_data);      
    }
    
    function a_fGetEvents($the_i_LucomId)
    {
         return $this->find('first',array('conditions'=>array('Event.user_id'=>$the_i_LucomId)));
    }
}
?>